package Classes.Components
{
	import Classes.Entity;
	import Classes.Skill;

	public class SkillComponent extends BaseComponent
	{
		private var m_skills:Object = new Object();
		
		public function SkillComponent(entity:Entity)
		{
			super(entity);
		}
		
		override public function update(delta:int):void{
			
		}
		
		public function getSkillByName(skillName:String, target:Entity=null):Skill{
			var skill:Skill = m_skills[skillName];
			skill.target = target;
			skill.range = skill.config.attributes['range'];
			skill.cooldown = skill.config.attributes['cooldown'];
			skill.castTime = skill.config.attributes['castTime'];
			return skill;
		}
		
		public function addSkillByName(skillName:String):void{
			var skill:Skill = getSkillPrototypeByName(skillName);
			m_skills[skillName] = skill;
			
			
		}
		
		private function getSkillPrototypeByName(skillName:String):Skill{
			var skill:Skill = new Skill(skillName,getEntity());
			skill.config = Main.configManager.getSkillConfigByName(skillName);
		
			return skill;
		}
	}
}